/*
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License version 2 as 
 * published by the Free Software Foundation.
 *
 * test_memory_pool.cpp is for what ...
 *
 * Version: ***: test_memory_pool.cpp  Sat Jul 23 10:29:07 2011 poponion Exp $
 *
 * Authors:
 *   Author poponion <huangcm85@gmail.com>
 *     -some work detail if you want 
 *
 */
#include <gtest/gtest.h>
#include "other/memory_pool.h"
#include <stdlib.h>

using namespace testing;

TEST(memorypool, basic)
{
  MemoryPool mPool;
  void * ret = mPool.mem_alloc();
  mPool.mem_free(ret);
  void * ret_new =mPool.mem_alloc();
  ASSERT_EQ(ret, ret_new);
  mPool.mem_free(ret_new);
  for(int32_t index = 0; index < 256 * 1024; ++index)
  {
    void* ret = mPool.mem_alloc();
    mPool.mem_free(ret);
  }
}

TEST(systemmalloc, basic)
{
  for(int32_t index = 0; index < 256 * 1024; ++index)
  {
    void* ret = malloc(4096);
    free(ret);
  }
}

int main(int argc, char **argv)
{
  InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
